//
//  HomeViewController.swift
//  MySwiftDemo
//
//  Created by dhc on 2019/11/29.
//  Copyright © 2019 lhd. All rights reserved.
//

import UIKit

class HomeViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
    }
    
    
    
    // MARK: - Navigation
    
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
        // set title for help screen
        
        print("prepare ===================>>>", segue.identifier as Any)
        if segue.identifier == "segueMy" {
            let destVc = segue.destination as! MyViewController
            destVc.navigationItem.title = "My"
        }
        
        //        // set title for help screen
        //        if segue.identifier == "segueHelp" {
        //            let destVc = segue.destination as! HelpViewController
        //            destVc.navigationItem.title = "Help"
        //        }
        //
        //        // set title for Settings screen
        //        if segue.identifier == "segueSettings" {
        //            let destVc = segue.destination as! SettingsViewController
        //            destVc.navigationItem.title = "Settings"
        //        }
    }
    
    
    //    @IBAction func leftButton(_ sender: Any) {
    //
    //        print("leftButton ===================>>>")
    //    }
    //    @IBAction func foMy(_ sender: Any) {
    //        print("goMyAction ===================>>>")
    //        self.performSegue(withIdentifier: "segueMy", sender: self)
    //    }
    //
    //    @IBAction func testButton(_ sender: Any) {
    //        print("testButton ===================>>>")
    //    }
    //    @IBAction func goLogin(_ sender: Any) {
    //        print("goLogin ===================>>>")
    //        navigationController?.popViewController(animated: true)
    //    }
//    @IBAction func goLogin(_ sender: UIBarButtonItem) {
//        print("goLogin ===================>>>")
//        //        navigationController?.show(ViewController(), sender: Any?.self)
//        //跳转
//        self.present(ViewController(), animated: true, completion: nil)
//    }
//
//    @IBAction func rightButton(_ sender: UIBarButtonItem) {
//        print("rightButton ===================>>>")
//        self.performSegue(withIdentifier: "segueMy", sender: self)
//    }
    
    @IBAction func goLogin(_ sender: UIButton) {
        print("goLogin ===================>>>")
        //        //        navigationController?.show(ViewController(), sender: Any?.self)
        //        //跳转
//                self.present(ViewController(), animated: true, completion: nil)
        //Main是storyboard的名字
        let sb = UIStoryboard(name: "Main", bundle: nil)
        //withIdentifier参数的值destinationPage是目的页面的Storyboard ID, 这个值在Storyboard里边进行设置。
        let destination = sb.instantiateViewController(withIdentifier: "login") as! ViewController;
//        destination.message = "传递的信息"
        
        // 从右向左滑出
        let transition = CATransition()
        transition.duration = 0.5
        transition.type = CATransitionType.push
        transition.subtype = CATransitionSubtype.fromRight
        transition.timingFunction = CAMediaTimingFunction(name:CAMediaTimingFunctionName.easeInEaseOut)
        view.window!.layer.add(transition, forKey: kCATransition)
        
        // 跳转
        self.present(destination, animated: false, completion: nil)
    }
    
    @IBAction func rightButton(_ sender: UIBarButtonItem) {
                print("rightButton ===================>>>")
    }
}
